// ShmReader.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include "ArrayShm.h"

ArrayShm gArrayShm;

int main(int argc, char* argv[])
{
    bool bInitStat  =  false;
    do
    {
        cout << "Going to open shm for reading "<<endl;
        bInitStat = gArrayShm.init(szFileName,eReader);
        if (false == bInitStat)
        {
            break;
        }
        const int nRuncnt = 10;

        for( int i = 0; i<nRuncnt; i++)
        {
            Data dt;
            int index  =  rand()%100000;
            bool bStatus =  false;
            bStatus = gArrayShm.GetValue(dt,index);
            if (true == bStatus)
            {
                cout<<"At index " << index << "data " << dt.acData <<endl;
            }           
            bStatus = gArrayShm.GetValue(dt,index);
            if (true == bStatus)
            {
                cout<<"At index " << index << " data " << dt.acData <<endl;
            }
            index  = 100000;
            bStatus = gArrayShm.GetValue(dt,index);
            if (true == bStatus)
            {
                cout<<"At index " << index << " data " << dt.acData <<endl;
            }
        }
        
    } while(0);
    return 0;
}

